package com.tac.service.impl;

import com.tac.common.Exception.CostomException;
import com.tac.common.result.Result;
import com.tac.dao.SlideDao;
import com.tac.pojo.Slide;
import com.tac.service.SlideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SlideServiceImpl implements SlideService {
    @Autowired
    private SlideDao slideDao;
    /**
     * 添加轮播图
     * @param file
     * @return
     */
    public Result save(String file){
        Integer integer = slideDao.save(file);
        if(integer>0){
           return Result.success(null,"success");
        }
        throw  new CostomException("添加失败");
    }
    /**
     * 删除轮播图
     * @param id
     * @return
     */
    public Result remove(Integer id){
        Integer integer = slideDao.remove(id);
        if(integer>0){
            return Result.success(null,"success");
        }
        throw  new CostomException("删除失败");
    }
    /**
     * 查看轮播图
     * @return
     */
    public Result<List<Slide>> selectAll(){
        List<Slide> slides = slideDao.selectAll();
        return Result.success(slides,"success");
    }
}
